import React,{ Component } from 'react';
import { Form, Icon, Input, Button,Cascader } from 'antd';
const FormItem = Form.Item;
class Cascaders extends Component {
	constructor(props) {
		super(props);
		this.state = {

		}
	}
	onChange=()=>{

	}
	onSubmitEvent(e) {
        e.preventDefault();
        console.log("提交");
        this.props.form.validateFields((err,value)=>{
            if(!err) {
               console.log('得到的值是：',value);
            }else {
                console.log('错误提示：',err);
            }
        });
    }
	render() {
		const { getFieldDecorator } = this.props.form;
		const options = [{
		  value: '浙江省',
		  label: '浙江省',
		  children: [{
		    value: 'hangzhou',
		    label: 'Hangzhou',
		    children: [{
		      value: 'xihu',
		      label: 'West Lake',
		    }],
		  }],
		}, {
		  value: 'jiangsu',
		  label: 'Jiangsu',
		  children: [{
		    value: 'nanjing',
		    label: 'Nanjing',
		    children: [{
		      value: 'zhonghuamen',
		      label: 'Zhong Hua Men',
		    }],
		  }],
		}];
		return (
			<Form onSubmit={ this.onSubmitEvent.bind(this)}>
                <FormItem style={{ width: '50%'}}>
                    {
                        getFieldDecorator('email',{
                        	initialValue: ['浙江省', 'hangzhou', 'xihu'],
                            rules: [{ required: true, message: '邮件客服不能为空!' }],
                        })(
                            <Cascader 
                            	options={options}
                            	onChange={ this.onChange }
                            	placeholder="请选择"
                            	//defaultValue={['浙江省', 'hangzhou', 'xihu']}
                            />
                        )
                    }
                    
                </FormItem>
                <FormItem>
                    <Button
                        type="primary"
                        htmlType="submit"
                    >
                        提交
                    </Button>
                </FormItem>
            </Form>
		)
	}
}

export default Form.create()(Cascaders);